#!/usr/bin/python3
# -*- coding: utf-8 -*-

import allure
from playwright.sync_api import Page, expect

from models.base_page import BasePage


class VipPage(BasePage):
    def __init__(self, page: Page):
        super().__init__(page)
        self.route = "vips"

    def check_vip_page_user_guide_element_to_be_visible(self):
        """检查使用指南元素是否可见"""
        with allure.step("检查VipPage:使用指南元素是否可见"):
            self.expect.to_be_visible(self.page.get_by_text("使用指南"))
            self.expect.to_be_visible(self.page.get_by_text("收起"))
            self.expect.to_contain_text(self.page.locator("#portal-vips-content"),
                                        "VBC网络IP是租户在云中公有的IP地址，租户可预先占用、查看、释放地址。")

    def check_vip_page_table_element_to_be_visible(self):
        """检查工具栏及table是否可见"""
        with allure.step("检查VipPage:工具栏及table是否可见"):
            self.expect.to_be_visible(self.page.locator(".css-1rvadt7"))
            self.expect.to_be_visible(self.page.get_by_role("button", name="+ 申请IP"))
            self.expect.to_be_visible(self.page.get_by_placeholder("请输入名称/ID/IP"))
            self.expect.to_be_visible(self.page.locator("#portal-vips-content").get_by_role("button").nth(1))
            self.expect.to_be_visible(self.page.get_by_role("combobox"))
